package com.infocollect.project.grant.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.infocollect.framework.aspectj.lang.annotation.Log;
import com.infocollect.framework.aspectj.lang.enums.BusinessType;
import com.infocollect.project.grant.domain.TappFrom;
import com.infocollect.project.grant.service.ITappFromService;
import com.infocollect.framework.web.controller.BaseController;
import com.infocollect.framework.web.domain.AjaxResult;
import com.infocollect.common.utils.poi.ExcelUtil;
import com.infocollect.framework.web.page.TableDataInfo;

/**
 * 报名表单管理Controller
 * 
 * @author infocollect
 * @date 2022-11-06
 */
@RestController
@RequestMapping("/grant/tappfrom")
public class TappFromDefaultController extends BaseController
{
    @Autowired
    private ITappFromService tappFromService;

    /**
     * 查询报名表单管理列表
     */
    @PreAuthorize("@ss.hasPermi('grant:tappfrom:list')")
    @GetMapping("/list")
    public TableDataInfo list(TappFrom tappFrom)
    {
        startPage();
        List<TappFrom> list = tappFromService.selectTappFromList(tappFrom);
        return getDataTable(list);
    }
    /**
     * 查询报名表单管理列表(下拉选择用）
     */
    @GetMapping("/listAll")
    public AjaxResult listAll()
    {
        TappFrom tappFrom = new TappFrom();
        tappFrom.setIsInput("启用");
        List<TappFrom> list = tappFromService.selectTappFromList(tappFrom);
        return AjaxResult.success(list);
    }
    /**
     * 导出报名表单管理列表
     */
    @PreAuthorize("@ss.hasPermi('grant:tappfrom:export')")
    @Log(title = "报名表单管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TappFrom tappFrom)
    {
        List<TappFrom> list = tappFromService.selectTappFromList(tappFrom);
        ExcelUtil<TappFrom> util = new ExcelUtil<TappFrom>(TappFrom.class);
        return util.exportExcel(list, "tappfrom");
    }

    /**
     * 获取报名表单管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('grant:tappfrom:query')")
    @GetMapping(value = "/{fid}")
    public AjaxResult getInfo(@PathVariable("fid") Long fid)
    {
        return AjaxResult.success(tappFromService.selectTappFromById(fid));
    }

    /**
     * 新增报名表单管理
     */
    @PreAuthorize("@ss.hasPermi('grant:tappfrom:add')")
    @Log(title = "报名表单管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TappFrom tappFrom)
    {
        return toAjax(tappFromService.insertTappFrom(tappFrom));
    }

    /**
     * 修改报名表单管理
     */
    @PreAuthorize("@ss.hasPermi('grant:tappfrom:edit')")
    @Log(title = "报名表单管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TappFrom tappFrom)
    {
        return toAjax(tappFromService.updateTappFrom(tappFrom));
    }

    /**
     * 删除报名表单管理
     */
    @PreAuthorize("@ss.hasPermi('grant:tappfrom:remove')")
    @Log(title = "报名表单管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{fids}")
    public AjaxResult remove(@PathVariable Long[] fids)
    {
        return toAjax(tappFromService.deleteTappFromByIds(fids));
    }
}
